package com.oak.designmode._02_strategy;

/**
 * context上下文
 *
 * @Description  由context调用运算类
 * @Author guoxy
 * @Date 2019/12/5 0005
 * @Version 1.0
 */
class Context {

    /**
     * 算法接口对象
     */
    private Operation operation;

    /**
     * 设置算法（加、减、乘、除）实例
     *
     * @param operation
     */
    public void setOperation(Operation operation) {
        this.operation = operation;
    }

    /**
     * 调用具体算法
     */
    public int excuteOperation(int a, int b) throws Exception {
        return operation.doCalculate(a, b);
    }
}
